
<!DOCTYPE html>
<!-- Website template by freewebsitetemplates.com -->
<html>
	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
		<title>Grade Bay</title>
		<link rel="stylesheet" href="gui.css" type="text/css" />
                <script type="text/javascript" src="jquery-latest.pack.js"></script>
                <script type="text/javascript" src="javascript.js"></script>
		
	</head>
	<body>
		<div class="page">
			<div class="header">
				<a href="index.php" id="logo"><img src="images/gradeBaylogo.png" width="330" height="79" alt=""/></a>
				<ul>
					<li class="selected"><a href="">STUDENT PROFILE</a></li>
					<?php
                                        
                                       
                                        if(!isset($_GET['studentID'])) $id=$_POST['studentID'];
                                        else $id=$_GET['studentID'];
                                            
                                        
                                        echo " <li><a href='viewStudentProfile.php?studentID=".$id."'>BACK</a></li>";
                                        ?>
			
				</ul>
			</div>
			<div class="body">
                            <div class="addsubject">
                            <?php
                                 include 'PHPClasses/DBAccess.php';
                                 include 'PHPClasses/StudentDBAccess.php';
                            
                                 
                                    if(!isset($_POST['studentID'])){
                                        $studID=$_GET['studentID'];

                                    }

                                    else{
                                        $studID=$_POST['studentID'];

                                    }
                                
                                    if(!isset($_GET['error'])){
                                                $_GET['error']=0;
                                     }

                                     if ($_GET['error']){ //If any errors display them  

                                             $errormsg = $_GET['error'] . ".<br>";
                                            echo "<p style='color:red;'>$errormsg</p>";

                                    }
                                    
                                    
                                   $DBAccess=new StudentDBAccess();
                                       
                                   $archivedLevels=array();
                                   $counter=0;
                                   
                                   
                                   
                                    
                                   $studentProfile=$DBAccess->viewProfile($studID);
                                   $studentContacts=$DBAccess->viewStudentContacts($studID);
                                    
                                    
                                    
                                   extract($studentProfile);
                                        
                                          $levelsArchived=$DBAccess->checkLevelifArchived($idStudent);
                                          
                                          while ($levelsArray = mysql_fetch_array($levelsArchived)){
                                              extract($levelsArray);
                                              $archivedLevels[$counter]=$level;
                                              $counter++;
                                              
                                            
                       
                                          }
                                          
                                          echo "<form name='studentIDForm' action='editStudentProfileDB.php' method='POST'>";
                                          echo "<table  id='formTable'><tr><td><p>Name of Student:</p></td><td><input class='tf_effect' style='padding:0;' value='".$studentName."' type='text' name='name' /></td></tr>";
                                          echo "<tr><td><p>Age:</p></td><td><input class='tf_effect' onkeypress='validate(event)' type='text' name='age' value='".$age."' MAXLENGTH='2'/></td></tr>";
                                          echo "<tr><td><p>Grade or Year Level: </p></td><td><select name='Level'>
                                                                         <option value='".$studentlvl."' select='selected'>".$studentlvl."</option>";
                                                                         
                                              
                                                                         if($studentlvl!='Grade 1'&& !in_array("Grade 1",$archivedLevels)) echo "<option value='Grade 1'>Grade 1</option>";
                                                                         if($studentlvl!='Grade 2'&& !in_array("Grade 2",$archivedLevels)) echo  "<option value='Grade 2'>Grade 2</option>";
                                                                         if($studentlvl!='Grade 3'&& !in_array("Grade 3",$archivedLevels)) echo "<option value='Grade 3'>Grade 3</option>";
                                                                         if($studentlvl!='Grade 4'&& !in_array("Grade 4",$archivedLevels)) echo "<option value='Grade 4'>Grade 4</option>";
                                                                         if($studentlvl!='Grade 5'&& !in_array("Grade 5",$archivedLevels)) echo "<option value='Grade 5'>Grade 5</option>";
                                                                         if($studentlvl!='Grade 6'&& !in_array("Grade 6",$archivedLevels))  echo "<option value='Grade 6'>Grade 6</option>";
                                                                         if($studentlvl!='1st Year'&& !in_array("1st Year",$archivedLevels)) echo "<option value='1st Year'>1st Year</option>";
                                                                         if($studentlvl!='2nd Year '&& !in_array("2nd Year",$archivedLevels)) echo "<option value='2nd Year'>2nd Year</option>";
                                                                         if($studentlvl!='3rd Year'&& !in_array("3rd Year",$archivedLevels)) echo "<option value='3rd Year'>3rd Year</option>";
                                                                         if($studentlvl!='4th Year'&& !in_array("4th Year",$archivedLevels)) echo "<option value='4th Year'>4th Year</option>
                                                                           </select></td></tr>";
                                          
                                          
                                          echo "<tr><td><p>Gender: </p></td><td><select name='gender' >
                                                                         <option  select='selected' value='".$gender."'>".$gender."</option>";  
                                                                          if($gender!='Male') echo "<option value='Male'>Male</option>";
                                                                          else  echo "<option value='Female'>Female</option>";        
                                                                          
                                                                          echo  "</select></td></tr>";
                                      echo "<tr><td><p>Address: </p></td><td><textarea class='tf_effectAddress' rows='4' cols='50' name='address' >".$address."</textarea></td></tr>";
                                      echo "<tr><td><p>Contact Numbers:</p></td>";
                                      
                                   
                                      echo "<td>";
         
                                      
                                    while($contacts = mysql_fetch_array($studentContacts)){
                                    extract($contacts);
                                      echo "<input class='tf_effect' type='text' onkeypress='validate(event)' name='contact[]' MAXLENGTH='11'value=".$number." /> ";
                                    
                                      }
                                      echo "</td></tr>";
                                      echo "</table>";
                                      echo "<input type='hidden' value=".$idStudent." name='studentID'/>
                                            <input type='hidden' name='submitted' value='1'>
                                            <br/><br/><center><input type='submit' id='saveStud' class='addmore' value='Save' name='EditProfile'/> </center>         
                                      </form>";
                                     
                                    $DBAccess->DBDisconnect();
                            ?>   
                            </div>
			</div>
			<div class="footer">
				
				<p>&#169; Copyright &#169; 2011. Company name all rights reserved</p>
				<div class="connect">
					<a href=""><img src="images/paragox.png" width=160" height="110" alt=""/></a>
					<a href=""><img src="images/fblogo.png" width=120" height="100" alt="" style="position:relative; left:-31px"/></a>
					<a href=""><img src="images/harmony.png" width=120" height="100" alt="" style="position:relative; left:0px"/></a>
				</div>
			</div>
		</div>
	</body>
</html>  